package com.sinping.qh.query.user;

import com.sinping.qh.query.base.Operator;
import com.sinping.qh.query.base.QueryParams;
import lombok.Data;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * 用户负责院系查询
 *
 * @author Tiansx
 * @create 2018-05-31 14:33
 **/
@Data
public class UserLabQuery implements QueryParams ,Serializable {
    static Map<String, String> aliasMap = new HashMap<>();
    static Map<String, Operator> operatorMap = new HashMap<>();

    /**
     * 用户名
     */
    private String userName;
    /**
     * 用户id
     */
    private String userId;

    /**
     * 姓名
     */
    private String fullName;

    /**
     * 所属单位id
     */
    private String unitId;
    /**
     * 负责院系
     */
    private String managerUnitName;

    static {
        aliasMap.put("userName", "user_name");
        aliasMap.put("userId", "user_id");
        aliasMap.put("fullName", "full_name");
        aliasMap.put("unitId", "unit_id");
        aliasMap.put("managerUnitName", "manager_unit_name");
        operatorMap.put("userName", Operator.regex);
        operatorMap.put("userId",Operator.eq);
        operatorMap.put("fullName",Operator.regex);
        operatorMap.put("unitId", Operator.eq);
        operatorMap.put("managerUnitName", Operator.regex);
    }

    @Override
    public String getAlias(String fieldName) {
        return aliasMap.getOrDefault(fieldName, fieldName);
    }

    @Override
    public Operator getOperators(String fieldName) {
        return operatorMap.getOrDefault(fieldName, Operator.eq);
    }

}
